<?php
/***************************************************************************
*                                request.php
 *
 *   Begin date           	: 
 *   Copyright            	: 
 *   Email                	: 
 ***************************************************************************/
defined('PHP5_PHP') or die("Application is stopping!!!");
//checkLogin();
//get
$task 		= php5GetParam($_REQUEST, 'task', '');
$currPage = php5GetParam($_REQUEST, 'p', 1);

if(!$currPage) {
	$currPage = 1;
}
$msg = '';
$smarty->setCompileDir(sprintf($php5RootTempalteCPath, ''));
$tpl = sprintf($php5TemplateFile, $language, 'adwords', 'items.tpl');
if(!is_file($tpl )) {
	die("can not find template");
}
//////////////////////////////
switch($task)
{
	case 'select':
		$category_key = php5GetParam($_REQUEST, 's_category', '');
		$php5Session->setVar("category_key", $category_key);
		$chk = '';
		break;
	case 'check':
		$chk = php5GetParam($_REQUEST, 'chk', '');
		$category_key = $php5Session->getVar("category_key");
		if(!$chk || !is_array($chk) || count($chk) < 1) {
			$msgAlert = "Please select items";
			break;
		}
		$php5Session->setVar("chk", $chk);
		$redirect = sefBuild($php5WebPath, 'index.php?o=adwords&m=reports', 1);
		break;	
	default:
		$category_key = $php5Session->getVar("category_key");
		$chk = $php5Session->getVar("chk");
		break;	
}
///////////////////////////
$categories = $define->REPORT_ITEMS($category_key);
$smarty->assign('msg', '');
$smarty->assign('chk', $chk);
$smarty->assign('categories', $categories);
$smarty->assign('action', sefBuild($php5WebPath, 'index.php?o=adwords&m=items&task=check', 1));
$smarty->assign('main', $smarty->fetch($tpl));
//$smarty->display($tpl);

return;

